<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="{:U('index')}" method="post">
        <input type="hidden" name="is_apple_cancle" value="{:I('is_apple_cancle')}">
    <div class="bjui-searchBar">
        <label>搜索：</label>
        <div role="group" class="btn-group">
          <select name="key" data-toggle="selectpicker">
            <option value="order_sn" <?php echo I("key")=="order_sn" ? "selected='true'" : "";?>>－网店订单号－</option>
            <option value="order_no" <?php echo I("key")=="order_no" ? "selected='true'" : "";?>>－商品货号－</option>
            <option value="user_name" <?php echo I("key")=="user_name" ? "selected='true'" : "";?>>－姓名－</option>
			<option value="mobile_phone" <?php echo I("key")=="mobile_phone" ? "selected='true'" : "";?>>－手机－</option>
            <option value="home_phone" <?php echo I("key")=="home_phone" ? "selected='true'" : "";?>>－电话－</option>
			<option value="address" <?php echo I("key")=="address" ? "selected='true'" : "";?>>－地址－</option>
            <option value="courie_number" <?php echo I("key")=="courie_number" ? "selected='true'" : "";?>>－快递单号－</option>
			<option value="host_order_sn" <?php echo I("key")=="host_order_sn" ? "selected='true'" : "";?>>－申请编号－</option>
          </select>
          <input type="text" name="value" class="form-control" size="15" value="{:I('value')}">
        </div>
		<div role="group" class="btn-group">
          <select name="express_id" onchange="javascript:$('.in .bjui-pageHeader #pagerForm').submit();" data-toggle="selectpicker">
            <option value="">－选择快递－</option>
            <?php foreach($expressList as $express):?>
            <option value="{$express.id}" <?php echo I("express_id")==$express['id'] ? "selected='true'" : "";?>>{$express.name}</option>
            <?php endforeach;?>
          </select>
        </div>
		<!--<div role="group" class="btn-group">
          <select name="changeExpressId" data-toggle="selectpicker">
            <option value="">－更换快递打印－</option>
            <?php foreach($expressList as $express):?>
            <option value="{$express.id}">{$express.name}</option>
            <?php endforeach;?>
          </select>
        </div>-->
        <div role="group" class="btn-group">
          <select name="invoice" data-toggle="selectpicker">
            <option value="">－是否开具发票－</option>
            <option value="1" <?php echo I("invoice")=="1" ? "selected='true'" : "";?>>－否－</option>
            <option value="2" <?php echo I("invoice")=="2" ? "selected='true'" : "";?>>－是－</option>
          </select>
        </div>
		<input type="checkbox" name="message_notes" id="j_custom_room" data-toggle="icheck" value="true" data-label="有卖家备注或买家留言" >
		<!-- <button type="submit" class="btn-default" data-icon="search">查询</button> -->
        <a class="btn btn-default" onclick="$(this).navtab('reloadForm', false, {data:{is_apple_cancle:0}})" data-icon="search">查询</a>
        <!--  <a class="btn btn-orange" href="javascript:;" onclick="$(this).navtab('reloadForm', true)"  data-icon="undo">清空查询</a> &nbsp;-->
        <div class="pull-right">
        <div class="btn-group">
          <button type="button" class="btn-default dropdown-toggle" data-toggle="dropdown" data-icon="copy">批量打印快递单/装箱发货<span class="caret"></span></button>
            <ul class="dropdown-menu right" role="menu">
                <li><a href="{:U('printListIndex')}" data-toggle="doajaxchecked"
                       data-confirm-msg="确定要打印选中项吗？" data-idname="ids" data-group="ids" data-type="GET"
                       data-callback="printListIndex" data-callbefore="checkPrint">打印快递单</a></li>
              <!--  <li><a href="{:U('binningSendOut')}" data-toggle="doajaxchecked"
                       data-confirm-msg="确定要装箱发货选中项吗？" data-idname="ids" data-group="ids" data-type="GET"
                        >装箱发货</a></li>-->
            </ul>
        </div>
      </div>
    </div>
	<div style="margin-bottom: 10px;"> 
	提示：<a href="javascript:;" onclick="$(this).navtab('reloadForm', false, {data:{is_apple_cancle:1}})">当前有 <b>
		  <font color="red">
  		  	<label id="lblFxsAppCancelCount">{$cancelOrder}</label>
  		  </font></b> <span id="lblFxsAppCancel">个订单，分销商申请取消。</span>
		  </a>
    </div>
  </form>
</div>
<div class="bjui-pageContent tableContent">
  <table class="table table-bordered table-hover table-striped table-top">
    <thead>
      <tr>
        <!-- 选择   订单号    网店单号    商品数量  订单状态   提交时间      操作  -->
          <!--出库单号  系统订单号  网店订单号  出库单状态  快递公司  生成时间-->
          <th width="26"><input type="checkbox" class="checkboxCtrl" data-group="ids" data-toggle="icheck"></th>
        <th data-order-field="outbound_sn" align="center">出库单号</th>
        <th data-order-field="order_no" align="center">系统订单号</th>
        <th data-order-field="order_sn" align="center">网店单号</th>
          <th align="center">快递公司</th>
        <th data-order-field="status" align="center">订单状态</th>
        <th data-order-field="status_time" align="center">提交时间</th>
      </tr>
    </thead>
    <tbody>
      <?php foreach($list as $arr):?>
      <tr>
        <td><input type="checkbox" name="ids" data-toggle="icheck" value="{$arr.order_id}"  <if condition="$arr.apple_cancel eq APPLE_CANCEL_YES || $arr.status eq EXPRESS_PRINT_SUCCESS">disabled="true" </if>> </td>
        <!-- 订单号 -->
        <td align="center"><a  data-toggle="navtab" data-options="{id:'ShippingManage{$arr['order_id']}', url:'{:U('ShippingManage/detailsShipping?orderId='.$arr['order_id'].'&navTabId=Order'.$arr['order_id'])}', title:'{$arr.order_sn}-订单详细'}">{$arr.outbound_sn}</a><br/>({$arr.user_name})</td>
        <!-- 系统订单号 -->
        <td align="center"><a  data-toggle="navtab" data-options="{id:'Order{$arr['order_id']}', url:'{:U('order/detailsOrder?orderId='.$arr['order_id'].'&isPrinter=1'.'&navTabId=Order'.$arr['order_id'])}', title:'{$arr.order_sn}-订单详细'}">{$arr.order_no}</a>
		<if condition="$arr.message_content neq ''">
		<span class="fa fa-flag" style="color:#FF0000"></span>
		</if>
		</td>
        <!-- 网店单号 -->
        <td align="center">{$arr.order_sn}</td>
        <!-- 快递公司 -->
        <td align="center">
            <?php
                foreach($expressList as $express){
                    if($express['id']==$arr['express_id']){
                        echo $express['name'];
                    }
                }
            ?>
        </td>
        <!-- 订单状态 -->
        <td align="center">
            <?php if($arr['status']==EXPRESS_PRINT_FAIL):?>
            <div class="red">(打印失败, 请重新打印)</div>
            <?php elseif($arr['status']==EXPRESS_PRINT_SUCCESS):?>
            <div class="blue">(已打印，请检查是否重复打印)</div>
            <?php else:?>
                {$arr.order_status}
            <?php endif;?>
			<if condition="$arr.is_barter eq '1'">
				<br />（换货订单）
			</if>
        </td>
        <!-- 提交时间 -->
        <td align="center">{:date('Y-m-d H:i:s', $arr['status_time'])}</td>
      </tr>
      <?php endforeach;?>
    </tbody>
  </table>
</div>
<div class="bjui-pageFooter">
  <div class="pages"> <span>每页&nbsp;</span>
    <div class="selectPagesize">
      <select data-toggle="selectpicker" data-toggle-change="changepagesize">
        <option value="{$pageSize}">{$pageSize}</option>
        <option value="{$pageSize*3}">{$pageSize*3}</option>
        <option value="{$pageSize*6}">{$pageSize*6}</option>
        <option value="{$pageSize*12}">{$pageSize*12}</option>
        <option value="{$pageSize*15}">{$pageSize*15}</option>
      </select>
    </div>
    <span>&nbsp;条，共 {$total} 条</span> </div>
  <div class="pagination-box" data-toggle="pagination" data-total="{$total}" data-page-size="{$pageSize}"
         data-page-current="{$pageCurrent}"></div>
</div>
<script>
    /**
     *  显示[打印快递单]页面
     */
    function printListIndex(result){
        var expressName = $(".in select[name=express_id]  option:selected").text();
        var data = {};
        data['expressId'] = $(".in select[name=express_id]").val();
        data['changeExpressId'] = $(".in select[name=changeExpressId]").val();
        data['ids'] = result['data']['ids'];
        var navtabId = 'printListIndex'+data['ids'].replace(/,/g,'_');
        data['navTabId'] = navtabId;
        var url = "{:U('printListIndex')}";
        var title = '打印快递单-'+expressName+'-'+$.md5(data['ids']).substring(0,8);
        $(this).navtab({id:navtabId, url:url, onClose:"closePrintListIndex", title:title, type:'POST', data:data});
    }

    /**
     *  关闭打印列表页面时执行的函数
     */
    function closePrintListIndex(){
        var currNavTabId = "{:I('request.navTabId')}";
        $(this).navtab('reload', {id:currNavTabId});          // 刷新当前窗口
    }

    /**
     *  显示[打印快递单]-前-操作
     */
    function checkPrint(){
        var expressId = $(".in select[name=express_id]").val();
        if(Number(expressId)>0){
            return true;
        }
        $(this).alertmsg('warn', "请选择选择快递方式");
        return false;
    }
</script>